<?php
$part = MiscUtils::getParam('part', 'settings');
$tag = MiscUtils::getParam('tag', 'settings');
$system_id = MiscUtils::getParam('sid', 0);
$path = 'instls/mods/' . basename(dirname(__FILE__));
$myPdo = DbUtils::createPdoInst();
$data = new stdClass();
$cond_vals = new stdClass();
$cond_vals->c = 't.id = :v1';
$cond_vals->v = array(':v1' => $system_id);
$tmp = DbUtils::get($myPdo, 'pz2_sys', $cond_vals, NULL, NULL, NULL, NULL, NULL)->d;
if (count($tmp) > 0) {
  $data->sys = $tmp[0];
}
?>
<style>
.clearfix:after {
  clear: both;
  content: ".";
  display: block;
  height: 0;
  visibility: hidden;
}
.tabPanel {
  margin-top: 10px;
  overflow: visible;
  padding-left: 5px;
}
.tabPanel .active {
  background: url("<?php echo $path; ?>/assets/imgs/tabs_on.gif") no-repeat scroll 0 0 transparent;
  color: #000000;
  display: block;
  font-weight: bold;
  height: 28px;
  margin-bottom: -4px;
  margin-top: -8px;
  padding-top: 6px;
  position: relative;
  width: 117px;
}
.tabPanel div {
  background: url("<?php echo $path; ?>/assets/imgs/tabs_common.gif") no-repeat scroll 0 0 transparent;
  color: #666666;
  cursor: pointer;
  display: block;
  float: left;
  height: 17px;
  padding: 4px 2px;
  text-align: center;
  width: 91px;
}
.clear {
  border-top: 1px solid #aaa !important;
  margin-top: -1px;
  margin-bottom: 5px;
}
</style>
<div class="tabPanel clearfix">
  <div <?php echo ($tag == 'settings') ? 'class="active"' : ''; ?> onclick="click_tag('settings', 'settings');">System</div>
  <?php if (isset($data->sys)) { ?>
  <div <?php echo ($tag == 'pages') ? 'class="active"' : ''; ?> onclick="click_tag('pages', 'pages');">Pages</div>
  <?php } ?>
</div>
<div class="clear"></div>
<div>
<?php include 'index_' . $part .'.php'; ?>
</div>
<script type="text/javascript" src="libs/jquery/jquery-1.6.2.min.js"></script>
<script type="text/javascript">
  $(function(){
    nav([
     { name: 'Systems',
       href: 'http://<?php echo URL . 'instls.php?mod=systems&menu=systems'; ?>' }, 
     { name: '<?php echo isset($data->sys) ? $data->sys->script . '.php' : 'New System'; ?>',
       href: '' }]);
  });

  function click_tag(part, tag) {
    location.href = 'http://<?php echo URL . 'instls.php?mod=system&menu=systems&part='; ?>' + part + '&tag=' + tag + '&sid=<?php echo $system_id; ?>';
  }
</script>